﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：吕海乐 
    //
    // 文件名：HospitalMange.aspx.cs
    // 文件功能描述：医院管理
    // 创建标识：吕海乐2009-05-25
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
// 审核时间：
// 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; 
using HZ.Supervise.IBLL;
using HZ.Supervise.Model;
using HZ.Supervise.Model.Enum;
using System.Data;
 

namespace HZ.Supervise.Web.SystemManage
{
    public partial class HospitalMange : BasePage
    {
        public HospitalMange()
        {
            this.ModuleNo = Module.基础信息库.ToString();
            PageOperateType = OperateType.医疗机构信息.ToString();
        }

        IBLL_PreWarning ip = HZ.Supervise.BLLFactory.IBLL_PreWarning();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.AreaControl1.InitAreaID = CurrentAccount.GetUser().Org.Area.AreaID;
                SetBind(); 
            }
        }

        /// <summary>
        /// 绑定所有医院
        /// </summary>
        private void SetBind()
        {
            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            int totalCount;
            HZ.Supervise.Model.Hospital mHospital = new HZ.Supervise.Model.Hospital();
            mHospital = getQuery();
            DataTable dt = ip.GetHospital(mHospital, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount); 
            AspNetPager1.RecordCount = totalCount;
            gvwHospital.DataSource = dt;
            gvwHospital.DataBind();
        }

        protected HZ.Supervise.Model.Hospital getQuery()
        {
            HZ.Supervise.Model.Hospital hos = new HZ.Supervise.Model.Hospital();
            hos.HospitalID = txtHospitalID.Text.Trim();
            hos.HospitalName = txtHospitalName.Text.Trim();
            switch (ddlIsCountry.SelectedValue)
            {
                case "0":
                    break;
                case "1":
                    hos.Levels = "'3','4','5','6'";
                    break;
                case "2":
                    hos.IsCountry = "'1','2','3','4'";
                    break;
                case "3":
                    hos.IsCountry = "'2'";
                    break;
                case "4":
                    hos.IsCountry = "'1'";
                    break;
                default:
                    break;
            }
            if (!string.IsNullOrEmpty(ddlIsGov.SelectedValue))
            {
                hos.IsGovernment = ddlIsGov.SelectedValue;
            }
            hos.AreaID = HZ.Supervise.Web.Function.GetAreaIDBySQL(AreaControl1.SelectedAreaID);
            
            return hos;
        }

        
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            //SetBind();
        }

        /// <summary>
        /// 翻页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            SetBind();
        }
         
        /// <summary>
        /// 删除医院
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvwHospital_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            
        }
    }
}
